/** 矩阵相乘 */
function multiply(out, a, b) {
    let a00 = a[0], a01 = a[1], a02 = a[2];
    let a10 = a[3], a11 = a[4], a12 = a[5];
    let a20 = a[6], a21 = a[7], a22 = a[8];
  
    let b00 = b[0], b01 = b[1], b02 = b[2];
    let b10 = b[3], b11 = b[4], b12 = b[5];
    let b20 = b[6], b21 = b[7], b22 = b[8];
  
    out[0] = b00 * a00 + b01 * a10 + b02 * a20;
    out[1] = b00 * a01 + b01 * a11 + b02 * a21;
    out[2] = b00 * a02 + b01 * a12 + b02 * a22;
  
    out[3] = b10 * a00 + b11 * a10 + b12 * a20;
    out[4] = b10 * a01 + b11 * a11 + b12 * a21;
    out[5] = b10 * a02 + b11 * a12 + b12 * a22;
  
    out[6] = b20 * a00 + b21 * a10 + b22 * a20;
    out[7] = b20 * a01 + b21 * a11 + b22 * a21;
    out[8] = b20 * a02 + b21 * a12 + b22 * a22;
    return out;
  }

  /**  相当于 rotate(45deg) */
  const a = [
    Math.cos(Math.PI/(180/45)), -Math.sin(Math.PI/(180/45)), 0,
    Math.sin(Math.PI/(180/45)), Math.cos(Math.PI/(180/45)), 0,
    0, 0, 1
  ];

  /** 相当于 translate(100px, 20px) */
  const b = [
    1, 0, 100,
    0, 1, 20,
    0, 0, 1
  ]

/** 相当于 
 * transform: translate(100px, 20px) rotate(45deg) 
 * 转换之后是 transform: matrix(0.7071067811865476, 0.7071067811865475, -0.7071067811865475,0.7071067811865476,100,20), 可以实现上边的内容
 * [a, b].reduceRight 可以传递多个参数，a、b 、c、d...
 */ 
const res = [a, b].reduceRight((a, b) => {
    return multiply([], b, a);
  }).map(i => Number(i.toFixed(2)));
  
  const res1 = res.slice(0, 3)
  const res2 = res.slice(3, 6)
  
console.log(res1);
console.log(res2);
console.log(res1.map((i, k) => [i, res2[k]]).flat())